<include file="Public/head"/>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css"/>
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<script src="http://img1.isou365.cn/paimai/yunying/js/city.js" type="text/javascript"></script>
<style>
    .xuanzhe ul li .menDao1 {  width: 300px;  }
    .xuanzhe ul li .menDao1 a {display: block;  background: #cecece;  color: #303030;  float: left;  width: 36px;  text-align: center;  height: 20px;  line-height: 20px;  cursor: pointer;  }
    .xuanzhe ul li .menDao1 .menHover {  background: #20ab4f;  color: #fff;  }
    .negotiation{width:915px;display: block;border:solid 1px #ccc;margin:15px 0 10px 10px;padding:20px 20px 0 20px; position: relative;}
    .negotiation2 {  margin: 10px 0 0 30px;  padding: 20px 20px 50px 20px;  position: relative;  }
    .negotiation h4 {  position: absolute;  color: #20ab4f;  top: -15px;  left: 30px;  font-size: 14px;  width: 90px;  text-align: center;  display: block;  height: 30px;  line-height: 30px;  background: #fff;  }
    .negotiation span, .negotiation2 span {  display: block;  float: left;  height: 28px;  line-height: 28px;  margin-right: 30px;  color: #333;  }
    #confirm_remark {  width: 715px;  border: solid 1px #dadada;  height: 60px;  resize: none;  padding: 5px;  float: left; }
</style>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="pmgl.ptqr"/>
    <div class="mianR">
        <h3 class="yonghu">
            <if condition="$status eq 0">
                平台确认详情
                <elseif condition="$status eq 1"/>
                跟踪确认详情
                <elseif condition="$status eq 3"/>
                确认成功详情
                <elseif condition="$status eq 5"/>
                确认失败详情
            </if>
        </h3>
        <div class="chezhu-xinxi">
            <div class="xinxi-conter xinxi-conter1" style="background: none;border: none">
                <h4 class="order_no">拍卖单号：<b>{$detail.order_no}</b></h4>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>
                    <if condition="$detail.is_dealer_breach eq 1">
                        仲裁人信息
                        <else />
                        自收人信息
                    </if>
                </h4>
                <ul>
                    <li class="clearfix">
                        <if condition="$detail.is_dealer_breach eq 1">
                            <em>仲裁人</em><em class="name-text1">{$detail.issue_done_emp}</em>
                            <em>仲裁人电话</em><em class="name-text">{$detail.issue_done_phone}</em>
                            <else />
                            <em>自收人</em><em class="name-text1">{$detail.dealer_contact_person}</em>
                            <em>自收人电话</em><em class="name-text">{$detail.dealer_contact_mobile}</em>
                        </if>
                    </li>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车商信息</h4>
                <ul>
                    <li class="clearfix">
                        <em style="width: 250px">名次</em>
                        <em style="width: 25%">车商联系人</em>
                        <em style="width: 25%">联系人电话</em>
                        <em style="width: 25%">车商出价</em>
                    </li>
                    <volist name="rank_data" id="rd">
                        <li class="clearfix">
                            <em style="width: 250px">第{$rd.sort}名</em>
                            <em style="width: 25%">{$rd.dealer_name}</em>
                            <em style="width: 25%">{$rd.contact_mobile}</em>
                            <em style="width: 25%">{$rd.price}</em>
                        </li>
                    </volist>
                </ul>
            </div>
            <br/>
            <div class="xinxi-conter xinxi-conter1">
                <h4>车辆信息（第{$detail.au_times}次拍卖）
                    <a href="{:U('Car/report',['car_id'=>$detail['car_id']])}" target="_blank">
                        <span style="float:right;padding-right: 10%;color:#20ab4f;">检测报告</span>
                    </a>
                </h4>
                <ul>
                    <li class="clearfix">
                        <em>车型</em><em class="name-text">{$detail.model}</em>
                        <em>排放标准</em><em class="dian-hua">{$detail.emission}</em>
                    </li>

                    <li class="clearfix">
                        <em>初登日期</em><em class="name-text">{$detail.first_reg_date}</em>
                        <em>颜色</em><em class="dian-hua">{$detail.car_color}</em>
                    </li>
                    <li class="clearfix">
                        <em>表显里程</em><em class="name-text">{$detail.pointer_mileage}万公里</em>
                        <em>车况级别</em><em class="name-text">{$detail.composite_state}{$detail.accident_level}</em>
                    </li>
                    <li class="clearfix">
                        <em>车辆注册地</em><em class="name-text">{$detail.reg_city}</em>
                        <em>车架号</em><em class="name-text">{$detail.vin}</em>
                    </li>
                    <li class="clearfix">
                        <em>过户限制</em><em class="name-text">{$detail.transfer_limit}</em>
                        <em>车牌号</em><em class="name-text">{$detail.plate_prefix}{$detail.plate_suffix}</em>
                    </li>
                    <li class="clearfix">
                        <em>渠道来源</em><em class="name-text">
                            <if condition="$detail.comefrom neq ''">
                                <?php if(empty($detail['comefrom_url'])):?>
                                <?php echo $show_from[$detail['comefrom']];?>
                                <?php else: ?>
                                <a href="{$detail.comefrom_url}" target="_blank"
                                   rel="noreferrer"><?php echo $show_from[$detail['comefrom']];?></a>
                                <?php endif;?>
                                <else/>
                                未知
                            </if>
                        </em>
                        <em>所在地</em><em class="name-text">{$detail.location_area}</em>
                    </li>
                </ul>
            </div>
            <br/>

            <div class="xinxi-conter xinxi-conter1">
                <h4>拍卖信息</h4>
                <ul>
                    <li class="clearfix">
                        <em>竞拍结束时间</em><em class="name-text">{$detail.bidding_end_time}</em>
                        <em>第一名出价</em><em class="name-text">{$detail.bidding_best_price}</em>
                    </li>
                    <li class="clearfix">
                        <em>保留价</em><em class="name-text">{$detail.reserve_price}元</em>
                        <em>建议价</em><em class="name-text">{$detail.suggest_price}</em>
                    </li>
                </ul>
            </div>
        </div>

        <empty name="trace_log">
            <else/>
            <h3 class="yonghu">系统跟踪日志</h3>
            <div class="yonghuText">
                <ul>
                    <php>$confirm_logs = array('0'=>'分配客服','1'=>'确认成功','2'=>'继续跟踪','3'=>'自收处理')</php>
                    <volist name="trace_log" id="list" key="k">
                        <li class="{$k%2==0?'xitongBg':''} clearfix">
                            <em class="huShi">{$list.createtime}</em>
                            <em>客服</em><em>{$list.real_name}</em><em>{$confirm_logs[$list['result']]}</em>
                            <em class="huShi">{$list.remark}</em>
                        </li>
                    </volist>
                </ul>
            </div>
        </empty>

        <if condition="$detail['status'] eq 5 and $detail['confirm_type'] eq 1">
            <h3 class="yonghu">请选择确认结果</h3>
            <div class="yuyue">
                <ul>
                    <li class="yuCurrent">确认成功</li>
                    <li>继续跟踪</li>
                    <li>确认失败</li>
                </ul>
            </div>

            <div class="listBox">
                <div class="yuList">
                    <div class="negotiation">
                        <h4>确认信息</h4>
                        <span><i>当前最高价：</i>{$detail.bidding_best_price_count}元</span>
                        <span><i>第一名加价</i><input type="text" value="" placeholder="请输入加价金额" id="fare"/></span>
                        <div class="clear"></div>
                        <em>拍卖最高价（<i class="auction-price"></i>元）= 当前最高价（<i class="cuur-price">{$detail.bidding_best_price_count}</i>元）+
                            第一名加价（<i class="fare-price">0.00</i>元）</em>
                    </div>
                    <div class="negotiation negotiation1">
                        <h4>结算信息</h4>
                        <if condition="$detail.is_dealer_breach eq 0">
                            <em>自收成交价（<i class="auction-price1">{$detail.self_receive_price}</i>元）</em>
                        </if>
                        <em>车商合手价（<i class="auction-price2"></i>元）= 拍卖最高价（<i class="cuur-price2">{$detail.bidding_best_price_count}</i>元）+
                            交易服务费（<i class="deal-price">0.00</i>元）+ 交付服务费（<i class="deliver-price">{$detail.transfer_fee}</i>元）</em>
                    </div>
                    <div class="negotiation2">
                        <span>备注</span>
                        <textarea id="confirm_remark" name="confirm_remark"></textarea>
                    </div>
                    <div class="yongBtn">
                        <?php if($detail['bidding_best_price_count']==0):?>
                        <input type="submit" disabled value="无人出价建议确认失败" class="queding queding_hui" />
                        <?php else:?>
                        <input type="submit" value="确定" class="queding platform_confirm_success"/>
                        <?php endif;?>
                        <input class="quxiao" type="submit" value="返回" onclick="history.back();">
                    </div>
                </div>

                <div class="yuList" style="display:none;">
                    <div class="xuanzhe1" style="background: none;border:none;margin:0;">
                        <ul>
                            <li class="genBtn1 clearfix">
                                <span class="gencuur">电话无人接听<input name="trace_reason" value="电话无人接听" type="checkbox"/></span>
                                <span class="gencuur">电话停机或关机<input name="trace_reason" value="电话停机或关机"
                                                                    type="checkbox"/></span>
                                <span class="gencuur">最近没时间<input name="trace_reason" value="最近没时间"
                                                                  type="checkbox"/></span>
                                <span class="gencuur">直接挂断电话<input name="trace_reason" value="直接挂断电话" type="checkbox"/></span>
                                <span class="gencuur">需要了解二手车拍卖<input name="trace_reason" value="需要了解二手车拍卖"
                                                                      type="checkbox"/></span>
                            </li>
                            <li class="clearfix">
                                <span>其他原因</span>
                                <input type="hidden" id="trace_reason" value="">
                                <textarea id="trace_remark" class="remark" name="trace_other_reason"></textarea>
                            </li>
                            <li class="clearfix">
                                <span>下次跟踪时间</span>
                                <input type="text" id="next_trace_time" name="next_trace_time" value="请选择下次跟踪时间"
                                       id="demoText9" class="xiaci" readonly/>
                            </li>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="button" value="确定" class="queding continue_trace"/>
                        <input class="quxiao" type="submit" value="返回" onclick="history.back();">
                    </div>
                </div>
                <div class="yuList" style="display:none;">
                    <div class="xuanzhe1" style="background: none;border:none;margin:0;">
                        <ul>
                            <li class="clearfix">
                                <span><b style="color: #FF0000;">*</b> 备注：</span>
                                <textarea id="self_receive_deal_remark" class="remark" placeholder="请输入确认失败备注"
                                          name="self_receive_deal_remark"></textarea>
                            </li>
                        </ul>
                    </div>
                    <div class="yongBtn">
                        <input type="button" value="确定" class="queding self_receive_deal"/>
                        <input class="quxiao" type="submit" value="返回" onclick="history.back();">
                    </div>
                </div>
            </div>
        </if>

    </div>
    <div class="clear"></div>
</div>
<script>
    $(document).ready(function () {
        $("#fare").val("");

        $(".auction-price").text((parseInt($(".cuur-price").text()) + parseInt($(".fare-price").text())).toFixed(2));

        //commssion_price
        var commssion_price = get_commssion_price($(".auction-price").text());
        $(".deal-price").text(parseInt(commssion_price).toFixed(2));

        $(".auction-price2").text((parseInt($(".cuur-price2").text()) + parseInt($(".deal-price").text()) + parseInt($(".deliver-price").text())).toFixed(2));
        $("#fare").blur(function () {
            var fare = $(this).val();
            if (fare == "" || parseInt(fare) == "NaN") {
                $(".fare-price").text('0.00');
            } else {
                var reg_fare = fare / 100;
                if (!/(^[0-9]\d*$)/.test(reg_fare)) {
                    shibai_alert('价格不正确,请输入整百的数字');
                    return false;
                }
                $(".fare-price").text(parseFloat(fare).toFixed(2));
            }
            $(".auction-price").text((parseInt($(".cuur-price").text()) + parseInt($(".fare-price").text())).toFixed(2));
            var auction_price = $(".auction-price").text();
            $(".cuur-price2").text(auction_price);
            $(".deal-price").text(parseInt(get_commssion_price(auction_price)).toFixed(2));
            $(".auction-price2").text((parseInt($(".cuur-price2").text()) + parseInt($(".deal-price").text()) + parseInt($(".deliver-price").text())).toFixed(2));
        });

        $("#next_trace_time").ymdateplugin({
            showTimePanel: true,
            changeMonth: true,
            changeYear: true,
            gotoCurrent: true,
            ampm: true
        });
    });

    //platform confirm success
    $('.platform_confirm_success').click(function () {

        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var fare = $("#fare").val()?$("#fare").val():0;
//        if (fare == "") {
//            shibai_alert('第一名加价价格不能为空');
//            return false;
//        }
        var reg_fare = fare / 100;
        if (!/(^[0-9]\d*$)/.test(reg_fare)) {
            shibai_alert('第一名加价价格不正确');
            return false;
        }
        var confirm_remark = $("#confirm_remark").val();
        var confirm_price = $(".auction-price").text();
        confirm_alert('<div style="color:red">您确定此辆车以' + confirm_price + '元成交吗？</div>', confirm_success);
        function confirm_success() {
            $('.determine').click(function () {
                colse_hide();
                platform_confirm_success();
            });
        }
        function platform_confirm_success() {
            var param = {
                        'order_id': order_id,
                        'owner_id': owner_id,
                        'dealer_id': "{$detail.success_dealer_id}",
                        'fare':fare,
                        'confirm_remark':confirm_remark
            };
            _myPost('/AuOrder/platform_confirm_success', param)
        }

    });
    //---platform continue trace
    $('.continue_trace').on('click', function () {
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        $('input[name=trace_reason]').each(function (i) {
            if (this.checked == true) {
                $('#trace_reason').val(this.value);
                return false;
            } else {
                $('#trace_reason').val('');
            }
        });
        var trace_reason_selected = $('#trace_reason').val();
        var trace_reason_other = $.trim($('textarea[name=trace_other_reason]').val());
        var trace_reason = trace_reason_selected ? trace_reason_selected : trace_reason_other;

        if (trace_reason == '') {
            shibai_alert('请选择或输入下次跟踪原因');
            return;
        }
        var next_trace_time = $('input[name=next_trace_time]').val();
        if (next_trace_time == '请选择下次跟踪时间') {
            shibai_alert('请选择下次跟踪时间');
            return;
        }
        confirm_alert('<div style="color:red">您确认继续跟踪吗？</div>', confirm_trace);
        function confirm_trace() {
            $('.determine').click(function () {
                colse_hide();
                platform_confirm_continue_trace();
            });
        }
        function platform_confirm_continue_trace() {
            var param = {
                'order_id': order_id,
                'owner_id': owner_id,
                'next_trace_time': next_trace_time,
                'next_trace_remark': encodeURIComponent(trace_reason)
            };
            _myPost('/AuOrder/platform_confirm_continue_trace', param)
        }

    });

    //----self recevice deal
    $(".self_receive_deal").on('click', function () {
        var order_id = '{$detail.order_id}';
        if (order_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var owner_id = '{$detail.owner_id}';
        if (owner_id == '') {
            shibai_alert('缺少必要参数，请联系管理员');
            return;
        }
        var self_receive_deal_remark = $('#self_receive_deal_remark').val();
        if (self_receive_deal_remark == '') {
            shibai_alert('请选择或输入确认失败备注');
            return;
        }
        confirm_alert('<div style="color:red">确定确认失败处理吗？</div>', confirm_self_receive_deal);
        function confirm_self_receive_deal() {
            $('.determine').click(function () {
                colse_hide();
                self_receive_deal();
            });
        }
        function self_receive_deal() {
            var params = {
                'order_id': order_id,
                'owner_id': owner_id,
                'remark': encodeURIComponent(self_receive_deal_remark)
            };
            _myPost('/AuOrder/platform_confirm_self_receive_deal', params)
        }
    });
    function _myPost(url, PostData) {
        $(".yunBei").css("display", "block").unbind('click')
        $(".loading").fadeIn();
        $.post(url, PostData, function (data) {
            if (data.code != 200) {
                $(".loading").fadeOut();
                $(".yunBei").css("display", "none")
                shibai_alert(data.msg);
                return false;
            }
            btn_alert("操作成功", 2000, function () {
                window.location.href = document.referrer;
            });
        }, 'json')
    }
    $(".xuanzhe ul li .menDao1 a").click(function () {
        $(".xuanzhe ul li .menDao1 a").removeClass("menHover");
        $(this).addClass("menHover");
        var index = $(".xuanzhe ul li .menDao1 a").index(this);
        $(".xuanzhe ul li .store1 .detailed").eq(index).show().siblings().hide();
    });

    /**
     * get commssion price
     * @param price
     */
    function get_commssion_price(price) {
        var PERCENTAGE = "{$percentage}";
        var MIN_FEE = "{$min_fee}";
        var MAX_FEE = "{$max_fee}";
        var p = price * PERCENTAGE;
        if (p <= MIN_FEE) {
            p = MIN_FEE;
        } else if (p >= MAX_FEE) {
            p = MAX_FEE;
        } else {
            p = Math.round(p / 100) * 100;
        }
        return p;
    }
</script>
<include file="Public/foot"/>